<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="no-cache">
    <meta http-equiv="Expires" content="-1">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta id="user_data" data-userid="{{ current_user.id }}"  data-role="{{ current_user.role }}" data-categoryid="{{ current_user.category }}">

    <title>{{ title }} | 虚拟桌面</title>
    <!-- Fancytree -->
    <link href="/isard-admin/static/vendor/fancytree/dist/skin-win8/ui.fancytree.css" rel="stylesheet">
    <!-- Bootstrap -->
    <link href="/isard-admin/vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="/isard-admin/vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- Font Linux -->
    <link href="/isard-admin/font-linux/font-linux.css" rel="stylesheet">
    <!-- ion.rangeSlider -->
    <link href="/isard-admin/vendors/ion.rangeSlider/css/ion.rangeSlider.css" rel="stylesheet">
    <link href="/isard-admin/vendors/ion.rangeSlider/css/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <!-- Datatables -->
    <link href="/isard-admin/vendors/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">
    <!-- PNotify -->
    <link href="/isard-admin/vendors/pnotify/dist/pnotify.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/isard-admin/vendors/pnotify/dist/pnotify.buttons.css" media="all" rel="stylesheet" type="text/css" />
    <!-- iCheck -->
    <link href="/isard-admin/vendors/iCheck/skins/flat/green.css" rel="stylesheet">
    <link href="/isard-admin/vendors/select2/dist/css/select2.min.css" rel="stylesheet">
    {% block css %}{% endblock %}
    <!-- Custom Theme Style -->
    <link href="/isard-admin/build/css/custom.css" rel="stylesheet">
    <!-- Isard Style Sheet-->
    <link href="/isard-admin/static/isard.css" rel="stylesheet">
  </head>

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
		        {% include 'sidebar.html' %}
          </div>
        </div>
        <!-- top navigation -->
        {% include 'header.html' %}
        <!-- /top navigation -->
        <div class="right_col" role="main">
          <!-- page content -->
          {% block content %}      
          {% endblock %}
          <!-- /page content -->
        </div>
        <!-- footer content -->
        {% include 'footer.html' %}
        <!-- /footer content -->
      </div>
    </div>
	  <div id="modal-lostconnection" class="modal fade" role="dialog" style="width:50%;margin-left:30%;margin-top:10%;z-index: 100000;">
      <div class="modal-admin">
        <div class="modal-content">
          <div class="row text-center"><h2 style="margin-bottom:5px">连接丢失</h2></div>
          <hr>
          <div class="row">
            <div class="col-md-1 col-sm-1 col-xs-12"></div>
            <div class="col-md-10 col-sm-10 col-xs-12">
              <div class="row text-center">无法联系服务器。网络或负载应有问题.</div>
              <br>
              <div class="row text-center" style="margin-bottom:25px">尝试重新连接...  
              </div>
            </div>
            <div class="col-md-1 col-sm-1 col-xs-12">
            </div>
          </div>
        </div>
	    </div>
	  </div>

    <!-- jQuery -->
    <script src="/isard-admin/vendors/jquery/dist/jquery.js"></script>
    <!-- Bootstrap -->
    <script src="/isard-admin/vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- NProgress -->
    <script src="/isard-admin/vendors/nprogress/nprogress.js"></script>
    <!-- Datatables -->
    <script src="/isard-admin/vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="/isard-admin/vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
   <!-- Ion.RangeSlider -->
    <script src="/isard-admin/vendors/ion.rangeSlider/js/ion.rangeSlider.min.js"></script>
    <!-- PNotify -->
    <script type="text/javascript" src="/isard-admin/vendors/pnotify/dist/pnotify.js"></script>
    <script type="text/javascript" src="/isard-admin/vendors/pnotify/dist/pnotify.confirm.js"></script>
    <script type="text/javascript" src="/isard-admin/vendors/pnotify/dist/pnotify.buttons.js"></script>
    <!-- validator -->
    <script src="/isard-admin/vendors/validator/validator.js"></script> 
    <!-- Parsley -->
    <script src="/isard-admin/vendors/parsleyjs/dist/parsley.min.js"></script>
    <!-- moment -->   
	  <script src="/isard-admin/vendors/moment/min/moment.min.js"></script>
    <!-- validator -->
    <script src="/isard-admin/vendors/iCheck/icheck.min.js"></script> 
    <!-- bootstrap-progressbar -->
    <script src="/isard-admin/vendors/bootstrap-progressbar/bootstrap-progressbar.min.js"></script>
    <!-- ECharts -->
    <script src="/isard-admin/vendors/echarts/dist/echarts.min.js"></script>
    <!-- Select2 -->
    <script src="/isard-admin/vendors/select2/dist/js/select2.full.min.js"></script>
    <!-- SocketIO -->
    <script src="/isard-admin/socketio/socket.io.min.js"></script>
    <!-- SerializeJSON -->
    <script src="/isard-admin/static/vendor/jquery.serializejson.js"></script>
    <!-- isard initializers -->
    <script src="/isard-admin/static/isard.js"></script>
    <!-- isard quota sse -->
	  <script src="/isard-admin/static/js/quota.js"></script>
    <!-- Requirements for fancy tree -->
    <script src="/isard-admin/static/vendor/fancytree/src/jquery-ui-dependencies/jquery-ui.min.js"></script>
    <script src="/isard-admin/static/vendor/fancytree/dist/jquery.fancytree.min.js"></script>
    <script src="/isard-admin/static/vendor/fancytree/src/jquery.fancytree.table.js"></script>
    <!-- Set user jwt header in ajax requests -->
    <script type="text/javascript">
      user_token = localStorage.getItem("token")
      $.ajaxSetup({
        headers: {
          "Authorization": "Bearer " + user_token
        },
        url: "/api/v3",
        beforeSend: function (jqXHR, settings) {
          // TODO: remove url check
          if (settings.url.split("/")[1] == 'admin') {
            settings.url = "/api/v3" + settings.url
          }
        }
      });

      // Ajax calls error handler for expired token error
      $( document ).ajaxError(function( event, jqxhr, settings, thrownError ) {
        if (jqxhr.status == 401 && jqxhr.responseJSON.error == 'unauthorized') {
          window.location = '/isard-admin/logout';
        }
      })

      $.fn.dataTable.ext.errMode = function ( settings, helpPage, message ) {
        console.log(message)
      };

      // If the user token is deleted from the localStorage perform a logout
      window.addEventListener('storage', (e) => {
        if (localStorage.token === undefined) {
          window.location = '/isard-admin/logout';
        } else if (e.key === 'token' && (e.newValue === null || e.newValue == ''))  {
          window.location = '/isard-admin/logout';
        }
      })
    </script>
    <!-- flashed messages with pnotify -->
    {% with messages = get_flashed_messages(with_categories=true) %}
	  {% if messages %}
		{% for category, message in messages %}
			<script type="text/javascript">
  			new PNotify({
				title: "{{ nav }}",
				text: "{{ message }}",
				hide: true,
				delay: 2000,
				//~ icon: 'fa fa-alert-sign',
				opacity: 1,
				type: "{{ category }}",
				addclass: "pnotify-center"
			});
			</script>	
		{% endfor %}
	  {% endif %}
	  {% endwith %}
    {% block pagescript %}{% endblock %}
  </body>
</html>
